<!doctype html>
<html>
<head>
	<#include "/pay/include/head_view.html" />
	<style>


	</style>
</head>

<body>

<div class="user_in" id="app">
	<i-form ref="myForm" :model="myform" :rules="ruleValidate" :label-width="10">
		<table id="sample-table-1" class="table table-striped table-bordered table-hover">
			<tbody>
			<!--
			<tr height="35px">
				<td width="15%">
					商户uid:
				</td>
				<td width="35%">
					{{myform.uid}}
				</td>
				<td width="15%">
					商户账号:
				</td>
				<td width="35%">
					{{myform.busAcc}}
				</td>
			</tr>
			-->
			<tr>
				<td>
					支付订单名称:
				</td>
				<td>
					{{myform.payName}}
				</td>
				<td>
					支付订单备注:
				</td>
				<td>
					{{myform.payDemo}}
				</td>
			</tr>
			<tr>
				<td>
					业务订单号:
				</td>
				<td>
					{{myform.orderid}}
				</td>
				<td>
					平台订单号:
				</td>
				<td>
					{{myform.rid}}
				</td>
			</tr>
			<tr>
				<td>
					订单金额:
				</td>
				<td>
					{{myform.prodPrice}}
				</td>
				<td>
					支付金额:
				</td>
				<td>
					{{myform.payImgPrice}}
				</td>
			</tr>
			<tr>
				<td>
					支付类型:
				</td>
				<td>
					{{myform.payTypeStr}}
				</td>
				<td>
					支付状态:
				</td>
				<td>
					{{myform.payStateStr}}
				</td>
			</tr>
			<tr>
				<td>
					创建时间:
				</td>
				<td>
					{{myform.createtime}}
				</td>
				<td>
					支付时间:
				</td>
				<td>
					{{myform.payTime}}
				</td>
			</tr>
			<tr>
				<td>
					支付扩展字段1:
				</td>
				<td>
					{{myform.payExt1}}
				</td>
				<td>
					支付扩展字段2:
				</td>
				<td>
					{{myform.payExt2}}
				</td>
			</tr>
			<tr>
				<td>
					收货人:
				</td>
				<td>
					{{myform.userName}}
					<br>
					{{myform.userPhone}}
				</td>
				<td>
					收货地址:
				</td>
				<td>
					{{myform.userAddress}}
				</td>
			</tr>
			<tr>
				<td>
					回调通知:
				</td>
				<td>
					{{myform.notifyStateStr}}
				</td>
				<td>
					回调次数:
				</td>
				<td>
					{{myform.notifyCount}}
				</td>
			</tr>

			</tbody>
		</table>

		<div>
			<i-button type="primary" icon="shuffle" @click="payNotify"> 发起回调 </i-button>
			<i-button type="error" icon="shuffle" @click="checkPay"> 我已收款 </i-button>
		</div>
</div>


</body>

	<script>
        var urls = {
            query:'/api/pay/paylog/queryone'
            ,save:'/api/pay/paylog/saveCurrUser'
            ,checkPay:'/api/pay/paylog/checkPay'
            ,payNotify:'/api/pay/paylog/payNotify'
        };

        var vm = new Vue({
            el: '#app',
            data:{
				myform: {
					isState:true,
					state: 1,
					restype:1,
                    logId:null,//主键
					test:"",
                    checkType:2
				},
                ruleValidate: {
                    email: [
                        { required: true, message: '请输入邮箱地址', trigger: 'blur' },
                        { type: 'email', message: '邮箱地址格式不对', trigger: 'blur' }
                    ]
                }
            },
            created:function(){
                if (this.getPara('logId')) {
                    this.myform.logId = this.getPara('logId');
                    this.loadData();
                }
            },
            methods: {
                loadData:function(){
                    $.ajax(
                        {
                            type: 'post', // 提交方式 get/post
                            url:urls.query, // 需要提交的 u
                            async:true,
                            cache:false,
                            dataType:'json',
                            data:this.myform,
                            success: function(ret){
                                if(ret.success){
                                    vm.myform = ret.data;
                                }
                            },
                            error:function(){
                                layer.alert("系统错误，请稍候再试");
                            }
                        });
                },
                getPara:function(name) {
                    var r = new RegExp("(\\?|#|&)" + name + "=([^&#]*)(&|#|$)");
                    var m = location.href.match(r);
                    return (!m ? "" : m[2]);
                },

                payNotify:function(){
                    var ii = layer.load();
					$.ajax(
						{
							type: 'post', // 提交方式 get/post
							url:urls.payNotify, // 需要提交的 u
							async:true,
							cache:false,
							dataType:'json',
							data:this.myform,
							success: function(ret){
                                layer.close(ii);
								if(ret.success){
									//vm.myform = ret.data;
									parent.layer.msg('发起回调成功');
									var i = parent.layer.getFrameIndex(window.name);
									parent.layer.close(i);
								}else{
									parent.layer.msg(ret.msg);
									var i = parent.layer.getFrameIndex(window.name);
									parent.layer.close(i);
								}
							},
							error:function(){
                                layer.close(ii);
								layer.alert("系统错误，请稍候再试");
							}
						});
                },
                checkPay:function(){

                    layer.confirm('此操作会将此订单手动设置为已收款状态，并且无法回退，确认要进行此操作么?', function(){
                        vm.myform.checkType=2;
                        $.ajax(
                            {
                                type: 'post', // 提交方式 get/post
                                url:urls.checkPay, // 需要提交的 u
                                async:true,
                                cache:false,
                                dataType:'json',
                                data:vm.myform,
                                success: function(ret){
                                    if(ret.success){
                                        //vm.myform = ret.data;
                                        parent.layer.msg('收款设置成功');
                                        var i = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(i);
                                    }else{
                                        parent.layer.msg(ret.msg);
                                        var i = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(i);
									}
                                },
                                error:function(){
                                    layer.alert("系统错误，请稍候再试");
                                }
                            });
                    })





                }
            }
        });

	</script>

<#include "/pay/include/hmt.html" />
</html>
